﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GenBenEditor
{
    public partial class MainWnd : Form
    {
        private Map map;

        public MainWnd()
        {
            InitializeComponent();
            ResetMap(new Map());
        }

        public void ResetMap(Map map)
        {
            this.map = map;
            miniMap.map = map;
            tilePalette.map = map;
            pageEditor.SetMembers(map, layerSelector, miniMap);

            miniMap.Invalidate();
            tilePalette.Invalidate();
            pageEditor.Invalidate();
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            ResetMap(new Map());
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "GenBen Map Files (*.bmap)|*.bmap";
            if (open.ShowDialog() == DialogResult.OK)
            {
                Map map = new Map();
                map.Load(open.FileName);
                ResetMap(map);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
